#ifndef GAMEBOARD_H
#define GAMEBOARD_H

#include "Touch_window.h"
#include "GUI.h"
#include "graph.h"
#include "Point.h"
#include "Chessman.h"
#include <vector>
#include <string>
#include <typeinfo>

using namespace Graph_lib;
using namespace std;

class Gameboard : public Touch_window {
public:
	Gameboard(Point xy, int w, int h, const string& title);
	bool pos_available ( int i, int j);	//check whether the postion is occupied
	int check_clear (int i, int j, int p, int q);	//check if there are chessman between two postioin,return the number of chessman
	void change_turn();
	string get_iconname (int i, int j, int col);
private:
	int board_last_j,board_last_i,board_last_p,board_last_q;
	Image* board;
	Image* initial;
	vector<Image*> win_lose;
	Menu new_game_menu;
	Button menu_button;
	Button quit0;
	Button quit1;
	Button restart;
	Button return_button;
	Button undo_button;

	Chessman* board_chess[10][9];	//map position in the board into an array, if the position is occupied by a chessman, 
									//then store the instance of the chessman into responding array
	Chessman* changed_orig;			//store the last move
	Chessman* changed_targ;
	int undo_counter[2];			//count the undo times
	Image* undo_reminder;
	Button continue_button;

	static void cb_menu(Address,Address);
	void menu_pressed();
	static void cb_new(Address,Address);
	void new_game_HvsH();
	static void cb_quit(Address,Address);
	void quit();
	static void cb_undo(Address,Address);
	void undo();
	static void cb_continue(Address,Address);
	void disappear();
	static void cb_return(Address,Address);
	void return_initial();
	static void cb_board(Address,Address);
	void choose_one(int i, int j);
	void move(int i, int j,int p, int q);
	void eat(int i, int j,int p, int q);
	static void cb_HvsH(Address,Address);
	static void cb_HvsR(Address,Address);
	static void cb_RvsH(Address,Address);
};

#endif

